/**
 * @Title: AttentionDynamicsActivity.java
 * @Copyright: XXX Co., Ltd. Copyright YYYY-YYYY,  All rights reserved
 * @Description: TODO<请描述此文件是做什么的>
 * @author: MeiYi
 * @data: 2015-12-7 上午10:20:14
 * @version: V1.0
 */

package artid.com.arttogo.fragment;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.drawable.BitmapDrawable;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.text.TextUtils;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnTouchListener;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.view.Window;
import android.view.WindowManager;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputMethodManager;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.RatingBar;
import android.widget.RatingBar.OnRatingBarChangeListener;
import android.widget.RelativeLayout;
import android.widget.ScrollView;
import android.widget.TextView;
import android.widget.TextView.OnEditorActionListener;

import com.android.volley.VolleyError;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.animation.GlideAnimation;
import com.bumptech.glide.request.target.SimpleTarget;
import com.hitomi.tilibrary.TransferImage;

import java.util.ArrayList;
import java.util.List;

import artid.com.arttogo.R;
import artid.com.arttogo.activity.AuctionAddRemind_Activity;
import artid.com.arttogo.activity.AuctionSpecialInfo_Activity;
import artid.com.arttogo.activity.BaseActivity;
import artid.com.arttogo.activity.CollecterActivity;
import artid.com.arttogo.activity.CollectionDetailPagerActivity;
import artid.com.arttogo.activity.DotPraiseUser_Activity;
import artid.com.arttogo.activity.LotDetailPagerActivity;
import artid.com.arttogo.activity.LotIntroActivity;
import artid.com.arttogo.activity.PhotoActivity;
import artid.com.arttogo.adapter.ArtListDetailAdapter;
import artid.com.arttogo.adapter.AuctionComment_Adapter;
import artid.com.arttogo.bean.ArtFavorite;
import artid.com.arttogo.bean.ArtistFollow;
import artid.com.arttogo.bean.AuctionCommentParser;
import artid.com.arttogo.bean.LotInfo;
import artid.com.arttogo.bean.OneStateIntParser;
import artid.com.arttogo.bean.ShareItem;
import artid.com.arttogo.bean.ShowPhoto;
import artid.com.arttogo.bean.SpecialInfoParser;
import artid.com.arttogo.db.Cache;
import artid.com.arttogo.network.AppUtil;
import artid.com.arttogo.network.VolleyBasic;
import artid.com.arttogo.network.VolleyCallback;
import artid.com.arttogo.network.VolleyData;
import artid.com.arttogo.network.VolleyMap;
import artid.com.arttogo.utils.MyBitmapImageViewTarget;
import artid.com.arttogo.utils.NetUtils;
import artid.com.arttogo.utils.ToastUtil;
import artid.com.arttogo.utils.VeDate;
import artid.com.arttogo.utils.VioceUtils;
import artid.com.arttogo.view.AndroidBug5497Workaround;
import artid.com.arttogo.view.CircleImageView;
import artid.com.arttogo.view.MyEditText;
import artid.com.arttogo.view.MyListView;
import artid.com.arttogo.view.ZoomScollView;
import artid.com.arttogo.view.pulllist.PullToRefreshLayout;
import artid.com.arttogo.view.pulllist.PullableScrollView;

import static artid.com.arttogo.utils.AlertUtils.setText;

/**
 * 拍品详情
 */
@SuppressLint("ValidFragment")
public class LotDetailFragment extends BaseFragment implements OnClickListener {
    private Context mContext;
    View v;
    //
    // 视图从上到下依次定义
    //
    RelativeLayout titleHide_RL;//标题/隐藏标题
    ImageView titleHideBackBtn;//标题返回键
    ImageView titleHideShareBtn;//左上角分享
    ImageView ivCollection;//右上角收藏
    TextView HideTitleName;//标题名称
    ImageView mImgMain;// 最上面的主图
    TextView mTextLotName;// 拍品名称
    TextView mTextLotNum;// 拍品数量
    TextView mTextIsRec;// 是否备案的文字
    ImageView isRecord;// 是否备案的文字
    TextView mTextEvaluaPrice;// 评估价格
    TextView mTextSoldPrice;// 拍卖成交价格
    ImageView imgLike, imgUncoll;// 红心的收藏
    LinearLayout mLineIcon;// 点赞头像
    TextView mTextLikeNum;// 点赞人数
    ImageView mImgCopHead;// 公司头像
    TextView mTextCopName;
    TextView mTextRecAndLotNum;
    TextView mTextSpecAndFollowNum;
    TextView mTextDetSFNum;
    ImageView mImgFollow;
    TextView mTextArtistName;
    // 所属专场
    RelativeLayout artistInfoRL;
    String artistID;
    ImageView mImgSpec;
    TextView mTextSpecState;
    TextView mTextSpecName;
    TextView mTextSpenRecAndLotNum;
    TextView mTextSpecTime;
    TextView mTextSpecCopName;
    TextView mTextSpecSite;
    Button mBtnAlarm;
    // 底部按钮
    View mViewCmt, mViewNote;
    View mViewCmtBackView;
    View mViewLotDetIntro;

    // 评论
    MyListView mListCmt;// 评论列表
    private TextView auc_org_det_more;// 点击加载更多
    private TextView lot_det_cmt;
    View cmt_view, cmt_view2, cmt_tag;// 评论的控件
    View hideCmt;// 启动评论后的隐藏控件
    private List<AuctionCommentParser> list = new ArrayList<AuctionCommentParser>();
    private List<AuctionCommentParser> more_list = new ArrayList<AuctionCommentParser>();
    AuctionComment_Adapter mCmtAdapter;
    private EditText replyEd;
    private TextView sendBtn;
    private RatingBar mRatingBar;
    private LinearLayout ratingBarLL;
    private int score;// 发表评论-评分
    private int replyPosition = -1;// -1的时候为评论反之都是评论
    private String replyID;// 回复ID
    /**
     * 控制左右滑的加载效果
     */
    Boolean isAdded = false;
    Boolean islike;
    Boolean isFollow = false;
    String id = "";
    String orgId = "0";//机构id
    PullToRefreshLayout mPullLayout;
    int pageIndex = 1, pagesize = 10;
    ZoomScollView mscroll;
    View hideView;
    ShareItem shareItem = null;
    ArtListDetailAdapter adapter;
    // Boolean isOrg = false;
    Boolean isReplyPerson = false;
    String commentId = "";
    private int width, height;
    ArrayList<String> imgurls = new ArrayList<String>(),
            strtitles = new ArrayList<String>();// 用于展示大图
    ShowPhoto photoItem = new ShowPhoto();
    private TextView lotid;
    private EditText lot_det_noteEd;
    private LinearLayout lot_det_noteLL, lot_det_bottomview_BtnLL;
    private Boolean isShowNoteKeyBoard = false;// 主要用户软键盘弹出和隐藏监听
    private ImageView imgVoice, lot_det_noteDelete, noteImage;
    private TextView notems;//笔记描述
    private Boolean isNote = false;// 判断是否有笔记
    LotInfo itemMain;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
//        HindStatusBar();
        mContext = getActivity();
        transferImage = TransferImage.getDefault(mContext);
        Bundle args = getArguments();
        id = args.getString("id");
    }

    public LotDetailFragment(String titileName) {
        super();
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        v = inflater.inflate(R.layout.activity_auction_lot_det, null);
        getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE | WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
        IntentFilter filter = new IntentFilter("com.LotDetailFragment.receiver");
        mContext.registerReceiver(broadcastReceiver, filter);
        titleHide_RL = (RelativeLayout) v.findViewById(R.id.LotDetailFragment_HideTitleRL);
        titleHideBackBtn = (ImageView) v.findViewById(R.id.LotDetailFragment_HideTitle_backBtn);
        titleHideBackBtn.setOnClickListener(this);
        ivCollection = (ImageView) v.findViewById(R.id.iv_auctionCollection);
        ivCollection.setOnClickListener(this);
//        HideTitleName= (TextView) v.findViewById(R.id.LotDetailFragment_HideTitle_titleName);
        titleHideShareBtn = (ImageView) v.findViewById(R.id.LotDetailFragment_HideTitle_shareBtn);
        titleHideShareBtn.setOnClickListener(this);
        notems = (TextView) v.findViewById(R.id.lot_det_note);
        mImgMain = (ImageView) v.findViewById(R.id.iv_coll_img);
        mImgMain.setOnClickListener(this);
        mViewLotDetIntro = (View) v.findViewById(R.id.lot_det_intro);
        mViewLotDetIntro.setOnClickListener(this);
        mTextLotName = (TextView) v.findViewById(R.id.lot_det_name);
        isRecord = (ImageView) v.findViewById(R.id.lot_det_isrecord);
        mTextEvaluaPrice = (TextView) v.findViewById(R.id.lot_det_evaluation);
        mTextSoldPrice = (TextView) v.findViewById(R.id.lot_det_sold_price);
        mLineIcon = (LinearLayout) v.findViewById(R.id.lot_det_layout_icon);
        mTextLikeNum = (TextView) v.findViewById(R.id.tv_like_sum);
        mTextLotNum = (TextView) v.findViewById(R.id.lot_det_lot);
        mImgCopHead = (ImageView) v.findViewById(R.id.lot_det_cop_headimg);
        mTextCopName = (TextView) v.findViewById(R.id.lot_det_cop_name);
        mTextRecAndLotNum = (TextView) v.findViewById(R.id.lot_det_cop_rec_lotnum);
        mTextDetSFNum = (TextView) v.findViewById(R.id.lot_det_cop_zc_follow);
        mTextSpenRecAndLotNum = (TextView) v.findViewById(R.id.lot_det_spec_rec_lotnum);
        mImgFollow = (ImageView) v.findViewById(R.id.lot_det_follow);
        mImgFollow.setOnClickListener(this);
        mTextArtistName = (TextView) v.findViewById(R.id.lot_det_artist_name);
        artistInfoRL = (RelativeLayout) v.findViewById(R.id.clt_det_artistInfoRL);
        artistInfoRL.setOnClickListener(this);
        mImgSpec = (ImageView) v.findViewById(R.id.lot_det_spec_img);
        mTextSpecState = (TextView) v.findViewById(R.id.lot_det_spec_state);
        mTextSpecName = (TextView) v.findViewById(R.id.lot_det_spec_name);
        mTextSpecAndFollowNum = (TextView) v.findViewById(R.id.lot_det_spec_rec_lotnum);
        mTextSpecTime = (TextView) v.findViewById(R.id.lot_det_spec_teime);
        mTextSpecCopName = (TextView) v.findViewById(R.id.lot_det_spec_cop_name);
        mTextSpecSite = (TextView) v.findViewById(R.id.lot_det_spec_site);
        mBtnAlarm = (Button) v.findViewById(R.id.lot_det_spec_alarm);
        mViewCmt = (View) v.findViewById(R.id.lot_det_cmt_view);
        mViewNote = (View) v.findViewById(R.id.lot_det_note_view);
        mViewNote.setOnClickListener(this);
        hideView = (View) v.findViewById(R.id.lot_det_hide);
        hideView.setOnClickListener(this);
        mViewCmtBackView = (View) v.findViewById(R.id.lot_det_cmt_background);
        mscroll = (ZoomScollView) v.findViewById(R.id.collection_detail_scroll);
        mscroll.setIsDrop(false);
//        mscroll.setOnScrollListener(scrollListener);
        lot_det_noteEd = (EditText) v.findViewById(R.id.lot_det_noteEd);
        lotid = (TextView) v.findViewById(R.id.tv_lot);
        lot_det_noteEd.setOnEditorActionListener(onEditorAction);
        lot_det_noteLL = (LinearLayout) v.findViewById(R.id.lot_det_noteLL);
        lot_det_bottomview_BtnLL = (LinearLayout) v.findViewById(R.id.lot_det_bottomview_BtnLL);
        imgVoice = (ImageView) v.findViewById(R.id.iv_vioce);
        imgVoice.setOnClickListener(this);
        noteImage = (ImageView) v.findViewById(R.id.iv_note);
        lot_det_noteDelete = (ImageView) v.findViewById(R.id.lot_det_noteDelete);
        lot_det_noteDelete.setOnClickListener(this);
        imgLike = (ImageView) v.findViewById(R.id.clt_det_like);
        imgLike.setOnClickListener(this);
        // 评论
        replyEd = (EditText) v.findViewById(R.id.AuctionComment_replyEd2);
        replyEd.setOnEditorActionListener(onEditorActionCmt);
        replyEd.setHint("123");
        sendBtn = (TextView) v.findViewById(R.id.AuctionComment_sendBtn);
        sendBtn.setOnClickListener(this);
        ratingBarLL = (LinearLayout) v.findViewById(R.id.AuctionComment_ratingBarLL);
        ratingBarLL.setVisibility(View.GONE);
        mRatingBar = (RatingBar) v.findViewById(R.id.AuctionComment_ratingBar);
        mRatingBar.setOnRatingBarChangeListener(onRatingBar);
        cmt_tag = (View) v.findViewById(R.id.lot_det_cmt_view);
        cmt_tag.setOnClickListener(this);
        cmt_view = (View) v.findViewById(R.id.cmt_view);
        cmt_view2 = (View) v.findViewById(R.id.cmt_view2);
        hideCmt = (View) v.findViewById(R.id.auc_org_hide);
        hideCmt.setOnClickListener(this);
        mListCmt = (MyListView) v.findViewById(R.id.lot_det_cmt_list);
        auc_org_det_more = (TextView) v.findViewById(R.id.auc_org_det_more);
        auc_org_det_more.setOnClickListener(this);
        lot_det_cmt = (TextView) v.findViewById(R.id.lot_det_cmt);
        mPullLayout = (PullToRefreshLayout) v.findViewById(R.id.refresh_view);
        mPullLayout.setOnRefreshListener(new PullToRefreshLayout.OnRefreshListener() {

            @Override
            public void onRefresh(PullToRefreshLayout pullToRefreshLayout) {
                // TODO Auto-generated method stub
                pageIndex = 1;

                reqData();
                getCmtData();
            }

            @Override
            public void onLoadMore(PullToRefreshLayout pullToRefreshLayout) {
                // TODO Auto-generated method stub
                // pullToRefreshLayout.setBottomDismiss();
                pageIndex++;
                getCmtData();
            }
        });
        adapter = new ArtListDetailAdapter(mContext);
        DisplayMetrics dm = new DisplayMetrics();
        getActivity().getWindowManager().getDefaultDisplay().getMetrics(dm);
        width = dm.widthPixels;
        height = dm.heightPixels;
        ViewGroup.LayoutParams lp = mImgMain.getLayoutParams();
        lp.width = width;
        lp.height = width * 3;
        mImgMain.setLayoutParams(lp);
        isViewSetup = true;
        isAdded = false;
        return v;
    }

    /**
     * 请求主数据
     */
    void reqData() {

        VolleyBasic.getInstance(getActivity()).post(Cache.lotInfo,
                VolleyMap.getInstance().lotInfo(id), LotInfo.class,
                new VolleyCallback() {
                    @Override
                    public void onSuccess(VolleyData vd) {
                        // TODO Auto-generated method stub
                        AndroidBug5497Workaround.assistActivity(getActivity());
                        final LotInfo item = (LotInfo) vd.getData();
                        itemMain = item;
                        // MainData = item;
                        orgId = item.getLotInfo().getJigou_id();
                        mTextSpecName.setText(item.getSpecInfo().getTitle());
                        if ("1".equals(item.getLotInfo().getIs_record())) {
                            isRecord.setVisibility(View.VISIBLE);
                        } else {
                            isRecord.setVisibility(View.GONE);
                        }
                        mTextSpecCopName.setText(item.getSpecInfo()
                                .getSeller_name());
                        mTextSpecSite.setText(item.getSpecInfo()
                                .getAuction_address());
                        if (TextUtils.isEmpty(item.getSpecInfo()
                                .getLotrecord_num())) {
                            item.getSpecInfo().setLotrecord_num("0");
                        }
                        if (TextUtils.isEmpty(item.getSpecInfo().getLot_num())) {
                            item.getSpecInfo().setLot_num("0");
                        }
                        mTextSpenRecAndLotNum.setText(item.getSpecInfo()
                                .getLotrecord_num()
                                + "件备案"
                                + "/"
                                + item.getSpecInfo().getLot_num() + "件拍品");
                        mImgSpec.setDrawingCacheEnabled(true);
                        Glide.with(mContext)
                                .load(item.getSpecInfo().getImgurl()
                                        + "_"
                                        + (Integer.parseInt(NetUtils
                                        .getDisplayMetrics(
                                                (Activity) mContext)
                                        .get(NetUtils.DM_WIDTH)) / 2)
                                        + "x10.png").asBitmap().centerCrop()
                                .placeholder(R.drawable.ic_menu_rotate)
                                .error(R.drawable.ic_menu_rotate)
                                .into(new MyBitmapImageViewTarget(mImgSpec));
                        artistID = item.getSpecInfo().getId();
                        int status = item.getSpecInfo().getStatus();
                        switch (status) {
                            case 0:
                                mTextSpecState.setText("已结束");
                                mTextSpecTime.setText("拍卖时间："
                                        + item.getSpecInfo().getStart_time() + "-"
                                        + item.getSpecInfo().getEnd_time());
                                break;
                            case 1:
                                mTextSpecState.setText("待预展");
                                mTextSpecTime.setText("预展时间："
                                        + item.getSpecInfo().getStart_time() + "-"
                                        + item.getSpecInfo().getEnd_time());
                                break;
                            case 2:
                                mTextSpecState.setText("预展中");
                                mTextSpecTime.setText("预展时间："
                                        + item.getSpecInfo().getStart_time() + "-"
                                        + item.getSpecInfo().getEnd_time());
                                break;
                            case 3:
                                mTextSpecState.setText("拍卖中");
                                mTextSpecTime.setText("拍卖时间："
                                        + item.getSpecInfo().getStart_time() + "-"
                                        + item.getSpecInfo().getEnd_time());
                                break;
                            default:
                                break;
                        }

                        final int is_remind = item.getSpecInfo().getIs_remind();
                        switch (is_remind) {
                            case 0:
                                // 0 已经开拍，不能点击
                                mBtnAlarm.setVisibility(View.INVISIBLE);
                                break;
                            case 1:
                                // 1.添加
                                mBtnAlarm.setText("添加提醒");
                                mBtnAlarm.setVisibility(View.VISIBLE);
                                break;
                            case 2:
                                // 2. 查看提醒
                                mBtnAlarm.setText("查看提醒");
                                mBtnAlarm.setVisibility(View.VISIBLE);
                                break;
                            default:
                                break;
                        }
                        mBtnAlarm.setOnClickListener(new OnClickListener() {

                            @Override
                            public void onClick(View v) {
                                // TODO Auto-generated method stub
                                // 提醒按钮
                                SpecialInfoParser mSpecialInfoParser = new SpecialInfoParser();
                                mSpecialInfoParser.setAddress(item
                                        .getSpecInfo().getAddress());
                                mSpecialInfoParser.setAuction_address(item
                                        .getSpecInfo().getAuction_address());
                                mSpecialInfoParser.setEnd_time(item
                                        .getSpecInfo().getEnd_time());
                                mSpecialInfoParser.setId(item.getSpecInfo()
                                        .getId());
                                mSpecialInfoParser.setImgurl(item.getSpecInfo()
                                        .getImgurl());
                                mSpecialInfoParser.setIs_remind(item
                                        .getSpecInfo().getIs_remind());
                                mSpecialInfoParser.setLot_num(item
                                        .getSpecInfo().getLot_num());
                                mSpecialInfoParser.setLotrecord_num(item
                                        .getSpecInfo().getLotrecord_num());
                                mSpecialInfoParser.setPreview_address(item
                                        .getSpecInfo().getPreview_address());
                                mSpecialInfoParser.setSeller_name(item
                                        .getSpecInfo().getSeller_name());
                                mSpecialInfoParser.setStart_time(item
                                        .getSpecInfo().getStart_time());
                                mSpecialInfoParser.setStatus(item.getSpecInfo()
                                        .getStatus());
                                mSpecialInfoParser.setTitle(item.getSpecInfo()
                                        .getTitle());
                                Intent i = new Intent(mContext,
                                        AuctionAddRemind_Activity.class);
                                i.putExtra("SpecialInfoParser",
                                        mSpecialInfoParser);
                                mContext.startActivity(i);
                            }
                        });

                        // 机构右侧的关注加号
                        if (item.getLotInfo().getIs_follow() == 1) {
                            isFollow = true;
                            mImgFollow
                                    .setImageResource(R.drawable.ppxq_btn_yguanz);
                        } else {
                            isFollow = false;
                            mImgFollow
                                    .setImageResource(R.drawable.ppxq_btn_guanz);
                        }
                        // 自上而下的填数据
                        mTextLotName.setText(item.getLotInfo().getLot_name());
//                        HideTitleName.setText(item.getLotInfo().getLot_name());
                        mTextLotNum.setText("LOT:" + item.getLotInfo().getChart_num());
                        String statue = String.valueOf(item.getSpecInfo().getStatus());
                        if (statue.equals("-1")) {
                            mTextSpecState.setText("未通过审核");
                        } else if (statue.equals("1")) {
                            mTextSpecState.setText("备案中");
                        } else if (statue.equals("2")) {
                            mTextSpecState.setText("已备案");
                        }

                        mTextEvaluaPrice.setText(item.getLotInfo().getUnit()
                                + " " + item.getLotInfo().getLot_val());
                        mTextSoldPrice.setText(item.getLotInfo().getUnit()
                                + item.getLotInfo().getLot_price());

                        mTextArtistName
                                .setText("艺术家 / " + item.getLotInfo().getRealname());
                        // 拍卖公司信息
                        Glide.with(mContext)
                                .load(item.getLotInfo().getLogo()
                                        + "_"
                                        + (Integer.parseInt(NetUtils
                                        .getDisplayMetrics(
                                                (Activity) mContext)
                                        .get(NetUtils.DM_WIDTH)) / 2)
                                        + "x10.png").asBitmap().centerCrop()
                                .placeholder(R.drawable.ic_menu_rotate)
                                .error(R.drawable.ic_menu_rotate)
                                .into(new MyBitmapImageViewTarget(mImgCopHead));
                        mTextCopName
                                .setText(item.getLotInfo().getSeller_name());
                        mTextRecAndLotNum.setText(item.getLotInfo()
                                .getLotrecord_num()
                                + "件备案/"
                                + item.getLotInfo().getLot_num() + "件拍品");
                        mTextDetSFNum.setText(item.getLotInfo()
                                .getSpecial_num()
                                + "个专场/"
                                + item.getLotInfo().getFollow_num() + "人关注");

                        if (item.getLotInfo().getIs_support().equals("1")) {
                            // AppUtil.isCollect = true;s
                            islike = true;
                            imgLike.setImageResource(R.drawable.jg_xq_good_sel);

                        } else {
                            // AppUtil.isCollect = false;
                            islike = false;
                            imgLike.setImageResource(R.drawable.ppxq_ico_dz);
                        }
                        // artistID = item.getArtist_id();
                        lotid.setText(item.getSpecInfo().getLot_num());
                        if (item.getLotInfo().getIs_note() == 1) {
                            // 是否有笔记0表示没有笔记，1表示有笔记
                            notems.setText("查看笔记");
                            noteImage.setImageResource(R.drawable.ico_chakanbiji);
                            isNote = true;
                            lot_det_noteEd.setText(item.getLotInfo().getNote_content().toString());
                        } else {
                            notems.setText("记笔记");
                            noteImage.setImageResource(R.drawable.zc_btn_bj);
                        }
                        mTextLikeNum
                                .setText(item.getLotInfo().getCommend_num());
                        listIcon = item.getLotInfo().getUserimg();
                        setHeadIcon(listIcon);

                        Glide.with(getActivity())
                                .load(item.getLotInfo().getImgurl()
                                        + AppUtil.picWidthUrl)
                                // .load("/storage/emulated/0/Tencent/QQfile_recv/55mb.jpg")
                                .asBitmap().into(new SimpleTarget<Bitmap>() {
                            @Override
                            public void onResourceReady(
                                    Bitmap resource,
                                    GlideAnimation<? super Bitmap> glideAnimation) {
                                ViewGroup.LayoutParams lp = mImgMain
                                        .getLayoutParams();
                                int w = resource.getWidth();
                                int h = resource.getHeight();

                                lp.width = width;
                                lp.height = h * width / w;

                                mImgMain.setLayoutParams(lp);
                                mImgMain.setMaxWidth(width);
                                mImgMain.setMaxHeight((int) (width * 5));
                                mImgMain.setImageBitmap(resource);
                                mscroll.setZoomView(mImgMain, true);
                                // System.out.println("bitmap="+bitmap.getWidth()+"="+bitmap.getHeight());

                            }
                        });

                        photoItem.setName(item.getLotInfo().getLot_name());
                        photoItem.setUrl(item.getLotInfo().getImgurl());
                        // // srcImg = item.getPic_url();
                        // //
                        // // textlike.setText("点赞  (" + item.getCommend_num() +
                        // ")");
                        // // textpl.setText("评论  (" + item.getComment_num() +
                        // ")");
                        // // textsc.setText("收藏  (" + item.getFav_num() + ")");
                        //
                        // shareItem = new ShareItem();
                        // shareItem.setContent(item.getDetail());
                        // shareItem.setImageUrl(item.getPic_url());
                        // shareItem.setTitle(item.getTitle());
                        // shareItem.setUrl(item.getSharelink());
                        // shareItem.setUid(item.getUid());
                        // shareItem.setHeadUrl(item.getHeadurl());
                        // shareItem.setAname(item.getRealname());
                        // CollectionDetailPagerActivity.listshare.set(
                        // CollectionDetailPagerActivity.index, shareItem);

                    }

                    @Override
                    public void onError(VolleyError volleyError) {
                        // TODO Auto-generated method stub

                    }
                });

        // reqCommentData();
        // reqisLike(id);
    }

    ArrayList<String> listIcon;

    void setHeadIcon(ArrayList<String> list) {

        mLineIcon.removeAllViews();
        for (int i = 0; i < list.size(); i++) {
            String headuri = list.get(i);

            Glide.with(getActivity()).load(headuri + AppUtil.picWidthSmallUrl)
                    // .load("/storage/emulated/0/Tencent/QQfile_recv/55mb.jpg")
                    .asBitmap().into(new SimpleTarget<Bitmap>() {
                @Override
                public void onResourceReady(Bitmap resource,
                                            GlideAnimation<? super Bitmap> glideAnimation) {
                    CircleImageView img = new CircleImageView(mContext);
                    img.setImageBitmap(resource);
                    android.widget.LinearLayout.LayoutParams params = new android.widget.LinearLayout.LayoutParams(
                            VeDate.dip2px(
                                    mContext, 30),
                            VeDate.dip2px(
                                    mContext, 30));
                    params.setMargins(
                            VeDate.dip2px(
                                    mContext, 10), 0,
                            VeDate.dip2px(
                                    mContext, 10), 0);
                    img.setLayoutParams(params);
                    mLineIcon.addView(img);
                }
            });
        }
    }

    View.OnClickListener listenerGz(final String id, final Boolean setFollow) {
        return new View.OnClickListener() {

            @Override
            public void onClick(View arg0) {
                // TODO Auto-generated method stub
                if (!AppUtil.LoginVer(getActivity())) {
                    reqFollowOrg(id, setFollow);
                }
            }
        };
    }

    void reqFollowOrg(String id, final Boolean setFollow) {
        String state = "";
        if (setFollow) {
            state = "1";
        } else {
            state = "2";
        }
        VolleyBasic.getInstance(getActivity()).post(
                Cache.lotFollow,
                VolleyMap.getInstance().lotFollow(
                        id, state),
                ArtistFollow.class, new VolleyCallback() {

                    @Override
                    public void onSuccess(VolleyData vd) {
                        // TODO Auto-generated method stub
                        ArtistFollow itemArtistFollow = (ArtistFollow) vd
                                .getData();

                        if (itemArtistFollow.getState().equals("1")) {
                            if (setFollow) {
                                isFollow = true;
                                mImgFollow
                                        .setImageResource(R.drawable.ppxq_btn_yguanz);
                                // gznum++;
                                // mViewFollow.setVisibility(View.GONE);
                                // mViewFollowed.setVisibility(View.VISIBLE);

                            } else {
                                isFollow = false;
                                mImgFollow
                                        .setImageResource(R.drawable.ppxq_btn_guanz);
                                // gznum--;
                                // mViewFollow.setVisibility(View.VISIBLE);
                                // mViewFollowed.setVisibility(View.GONE);
                            }
                            // mTextLikeNum.setText(String.valueOf(gznum)+
                            // "人关注");
                        }
                    }

                    @Override
                    public void onError(VolleyError volleyError) {
                        // TODO Auto-generated method stub

                    }
                });
    }

    Boolean isViewSetup = false;

    // 让缓存的页面不加载

    @Override
    public void setUserVisibleHint(boolean isVisibleToUser) {
        super.setUserVisibleHint(isVisibleToUser);
        if (isVisibleToUser) {
            // 相当于Fragment的onResume
            if (isViewSetup && isAdded == false) {
                reqData();
                getCmtData();
                mscroll.fullScroll(ScrollView.FOCUS_UP);
                disableAutoScrollToBottom();
            }
        } else {
            isAdded = true;
            // id = oldid;

        }
    }

    /**
     * 处理侧滑自动滚到底部
     */
    private void disableAutoScrollToBottom() {
        mscroll.setDescendantFocusability(ViewGroup.FOCUS_BEFORE_DESCENDANTS);
        mscroll.setFocusable(true);
        mscroll.setFocusableInTouchMode(true);
        mscroll.setOnTouchListener(new OnTouchListener() {

            @Override
            public boolean onTouch(View arg0, MotionEvent arg1) {
                // TODO Auto-generated method stub
                arg0.requestFocusFromTouch();
                return false;
            }
        });
    }

    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onActivityCreated(savedInstanceState);
        if (LotDetailPagerActivity.isCreat) {
            reqData();
            getCmtData();
            mscroll.fullScroll(ScrollView.FOCUS_UP);
            disableAutoScrollToBottom();
            CollectionDetailPagerActivity.isCreat = false;
        }

    }

    // PopupWindow mPw;
    // TextView report, reply, cancel;

    private void getCmtData() {
        VolleyBasic.getInstance(getActivity()).post(
                Cache.jgcommentList,
                VolleyMap.getInstance().jigou_commentList(pageIndex, 10, id,
                        "4"), AuctionCommentParser.class, new VolleyCallback() {

                    @SuppressWarnings({"unchecked", "static-access"})
                    @Override
                    public void onSuccess(VolleyData vd) {
                        // TODO Auto-generated method stub
                        mPullLayout.loadmoreFinish(PullToRefreshLayout.SUCCEED);
                        list = (List<AuctionCommentParser>) vd.getList();
                        if (!list.isEmpty()) {
                            more_list.clear();
                            more_list.addAll(list);
                        }
                        lot_det_cmt.setText("说说这个机构(" + more_list.size() + ")");
                        if (mCmtAdapter == null) {
                            mCmtAdapter = new AuctionComment_Adapter(mContext, "4",
                                    more_list);
                            mListCmt.setAdapter(mCmtAdapter);
                        }
                        mCmtAdapter.notifyDataSetChanged();
                    }

                    @Override
                    public void onError(VolleyError volleyError) {
                        // TODO Auto-generated method stub

                    }
                });
    }

    /**
     * 点击红心，请求 给拍品点赞，头像列表左侧的
     */
    void reqLike(final String id, final Boolean setFollow) {
        String state = "";
        if (setFollow) {
            state = "1";
        } else {
            state = "2";
        }
        VolleyBasic.getInstance((Activity) mContext).post(Cache.commentSupport,
                VolleyMap.getInstance().commentSupport(id, state, "5"),
                OneStateIntParser.class, new VolleyCallback() {

                    @Override
                    public void onSuccess(VolleyData vd) {
                        // TODO Auto-generated method stub
                        if (vd.getCode() == -99) {
                            AppUtil.Logout(getActivity());
                            AppUtil.LoginVer(getActivity());
                            return;
                        }
                        String numstr = mTextLikeNum.getText().toString();
                        if (TextUtils.isEmpty(numstr)) {
                            numstr = "0";
                        }
                        int num = 0;
                        try {
                            num = Integer.valueOf(numstr);
                        } catch (Exception e) {
                            // TODO: handle exception
                        }
                        String head = AppUtil.getUser().getHeadurl();
                        if (setFollow) {
                            islike = true;
                            imgLike.setImageResource(R.drawable.jg_xq_good_sel);
                            num++;
                            mTextLikeNum.setText(num + "");
                            listIcon.add(head);
                        } else {
                            islike = false;
                            num--;
                            mTextLikeNum.setText(num + "");

                            imgLike.setImageResource(R.drawable.ppxq_ico_dz);
                            if (listIcon.size() != 0) {
                                listIcon.remove(listIcon.indexOf(head));
                            }
                        }
                        setHeadIcon(listIcon);

                    }

                    @Override
                    public void onError(VolleyError volleyError) {
                        // TODO Auto-generated method stub

                    }
                });
    }

    void reqCollect(final String id, final Boolean setCollect) {
        String state = "";
        if (setCollect) {
            state = "1";
        } else {
            state = "2";
        }
        VolleyBasic.getInstance((Activity) mContext).post(
                Cache.artFavorite,
                VolleyMap.getInstance().artFavorite(
                        AppUtil.getUser().getToken(), id, state),
                ArtFavorite.class, new VolleyCallback() {

                    @Override
                    public void onSuccess(VolleyData vd) {
                        // if (vd.getCode() == -99) {
                        // AppUtil.Logout(getActivity());
                        // AppUtil.LoginVer(getActivity());
                        // return;
                        // }
                        // // TODO Auto-generated method stub
                        // ArtFavorite itemArtistFollow = (ArtFavorite) vd
                        // .getData();
                        // String text = textsc.getText().toString();
                        // String strnum = text.substring(text.indexOf("(") + 1,
                        // text.indexOf(")"));
                        // if (itemArtistFollow.getState().equals("1")) {
                        // if (setCollect) {
                        // imgColl.setVisibility(View.VISIBLE);
                        // imgUncoll.setVisibility(View.GONE);
                        // try {
                        // int num = Integer.valueOf(strnum);
                        // num++;
                        // textsc.setText("收藏  ("
                        // + String.valueOf(num) + ")");
                        // } catch (Exception e) {
                        // // TODO: handle exception
                        // }
                        // } else {
                        // imgColl.setVisibility(View.GONE);
                        // imgUncoll.setVisibility(View.VISIBLE);
                        // try {
                        // int num = Integer.valueOf(strnum);
                        // num--;
                        // textsc.setText("收藏  ("
                        // + String.valueOf(num) + ")");
                        // } catch (Exception e) {
                        // // TODO: handle exception
                        // }
                        // }
                        // }

                    }

                    @Override
                    public void onError(VolleyError volleyError) {
                        // TODO Auto-generated method stub

                    }
                });
    }


    @Override
    public void onClick(View arg0) {
        // TODO Auto-generated method stub
        Boolean isCollection = false;//是否已被收藏
        switch (arg0.getId()) {

//            case R.id.LotDetailFragment_title_shareBtn:
//                //分享
//                if (itemMain != null) {
//                    if (itemMain.getLotInfo().getIs_collection() == 0) {
//                        isCollection = false;
//                    } else {
//                        isCollection = true;
//                    }
//                    AppUtil.shareAuction(mContext, "4", itemMain.getLotInfo().getLot_name(), itemMain.getLotInfo().getLot_memo(), itemMain.getLotInfo().getImgurl(),
//                            itemMain.getLotInfo().getShareurl() + "&type=1", itemMain.getLotInfo().getId(), isCollection);
//                }
//                break;
            case R.id.LotDetailFragment_HideTitle_shareBtn:
                //分享
                if (itemMain != null) {
                    if (itemMain.getLotInfo().getIs_collection() == 0) {
                        isCollection = false;
                    } else {
                        isCollection = true;
                    }
                    AppUtil.shareAuction(mContext, "4", itemMain.getLotInfo().getLot_name(), itemMain.getLotInfo().getLot_memo(), itemMain.getLotInfo().getImgurl(),
                            itemMain.getLotInfo().getShareurl() + "&type=1", itemMain.getLotInfo().getId(), isCollection);
                }
                break;
//            case R.id.LotDetailFragment_title_backBtn:
//                getActivity().finish();
//                break;
            case R.id.iv_auctionCollection:
                String state;
                if (itemMain.getLotInfo().getIs_collection() == 0) {
                    state = "1";
                } else {
                    state = "2";
                }
                VolleyBasic.getInstance((Activity) mContext).post(Cache.addCollection,
                        VolleyMap.getInstance().addCollection(id, "4", state),
                        OneStateIntParser.class, new VolleyCallback() {

                            @Override
                            public void onSuccess(VolleyData vd) {
                                // TODO Auto-generated method stub
                                OneStateIntParser mBean = (OneStateIntParser) vd.getData();
                                if (mBean.getState() == 1) {
                                    if (itemMain.getLotInfo().getIs_collection() == 0) {
                                        itemMain.getLotInfo().setIs_collection(1);
                                    } else {
                                        itemMain.getLotInfo().setIs_collection(0);
                                    }
                                } else {
                                    ToastUtil.toast(mContext, "操作失败");
                                }
                            }

                            @Override
                            public void onError(VolleyError volleyError) {
                                // TODO Auto-generated method stub
                            }
                        });
                break;
            case R.id.LotDetailFragment_HideTitle_backBtn:
                getActivity().finish();
                break;
            case R.id.clt_det_pl:
                mscroll.fullScroll(ScrollView.FOCUS_DOWN);
                break;
            case R.id.clt_det_icon_view:
                Intent intent2 = new Intent(mContext, DotPraiseUser_Activity.class);
                intent2.putExtra("id", id);
                startActivity(intent2);
                break;
            case R.id.clt_det_chat:

                // String headUrl;
                // if (!StringUtils.isEmpty(MainData.getHeadurl())) {
                // headUrl = MainData.getHeadurl();
                // } else {
                // headUrl =
                // "http://172.16.0.3/upload/artPlatform/Addons/Avatar/default_128_128.png";
                // }
                // AppUtil.goChat(mContext, MainData.getUid(), headUrl,
                // MainData.getRealname());

                break;

            case R.id.iv_coll_img:
//                new TransferImage.Builder(getActivity())
//                        .setBackgroundColor(Color.parseColor("#000000"))
//                        .setImageUrls(photoItem.getUrl())
//                        .setOriginImages(mImgMain)
//                        .setup(transferImage)
//                        .show();
                Intent intent = new Intent(getActivity(), PhotoActivity.class);
                intent.putExtra("item", photoItem);
                startActivity(intent);
                break;
            case R.id.view_like:

                // if (imgLike.getVisibility() == View.VISIBLE) {
                // + AppUtil.picWidthUrl)
                // // .load("/storage/emulated/0/Tencent/QQfile_recv/55mb.jpg")
                // .asBitmap()
                // .into(new SimpleTarget<Bitmap>() {
                // @Override
                // public void onResourceReady(
                // Bitmap resource,
                // GlideAnimation<? super Bitmap> glideAnimation) {
                // CircleImageView img = new CircleImageView(
                // mContext);
                // img.setImageBitmap(resource);
                // android.widget.LinearLayout.LayoutParams params = new
                // android.widget.LinearLayout.LayoutParams(
                // com.aicpsp.artworkartc.util.VeDate
                // .dip2px(mContext,
                // 30),
                // com.aicpsp.artworkartc.util.VeDate
                // .dip2px(mContext,
                // 30));
                // img.setLayoutParams(params);
                // params.setMargins(com.aicpsp.artworkartc.util.VeDate
                // .dip2px(mContext,
                // 10), 0, com.aicpsp.artworkartc.util.VeDate
                // .dip2px(mContext,
                // 10), 0);
                // mLineIcon.addView(img);
                // }
                // });
                // } else {
                // reqLike(id, true);
                // }

                break;

            case R.id.view_collect:
                if (AppUtil.LoginVer(getActivity())) {
                    return;
                }
                if (imgLike.getVisibility() == View.VISIBLE) {
                    reqCollect(id, false);
                } else {
                    reqCollect(id, true);
                }

                break;

            case R.id.lot_det_hide:
                // 软件盘弹出点击空白处
                if (lot_det_noteLL.getVisibility() == View.VISIBLE) {
                    hideNoteKeyBoard();
                } else {
                    hideKeyBoard();
                    replyEd.setVisibility(View.GONE);
                    hideView.setVisibility(View.GONE);
                    mViewCmtBackView.setVisibility(View.GONE);
                }

                break;
            case R.id.auc_org_det_more:
                pageIndex++;
                getCmtData();
                break;
            case R.id.lot_det_cmt_view:
                isReplyPerson = false;
                startComment("");

                break;
            case R.id.auc_org_hide:
                if (cmt_view.getVisibility() == View.VISIBLE) {
                    hideKeyBoard();
                    ratingBarLL.setVisibility(View.GONE);
                    cmt_view.setVisibility(View.GONE);
                    cmt_view2.setVisibility(View.GONE);
                    hideCmt.setVisibility(View.GONE);
                }
                break;

            case R.id.AuctionComment_sendBtn:
                // 发送信息
                if (!TextUtils.isEmpty(replyEd.getText().toString().trim())) {
                    if (replyPosition == -1) {
                        sendComment();
                    } else {
                        replyComment();
                    }
                } else {
                    ToastUtil.toast(mContext, "评论不能为空");
                }
                break;
            case R.id.lot_det_edit:
                hideView.setVisibility(View.VISIBLE);
                break;
            case R.id.clt_det_more:

                // if (AppUtil.isCollect) {
                // AppUtil.shareClt(mContext, MainData.getTitle(),
                // MainData.getDetail(), MainData.getPic_url(),
                // MainData.getSharelink(), id, true);
                // } else {
                // AppUtil.shareClt(mContext, MainData.getTitle(),
                // MainData.getDetail(), MainData.getPic_url(),
                // MainData.getSharelink(), id, false);
                // }

                break;
            case R.id.clt_det_back:
                getActivity().finish();
                break;
            case R.id.lot_det_follow:
                if (isFollow) {
                    reqFollowOrg(orgId, false);
                } else {
                    reqFollowOrg(orgId, true);
                }
                break;
            case R.id.clt_det_like:

                if (listIcon != null) {
                    if (islike) {
                        reqLike(id, false);
                    } else {
                        reqLike(id, true);
                    }
                }
                setHeadIcon(listIcon);
                break;
            case R.id.clt_det_artistInfoRL:
                //专场详情
                intent = new Intent(mContext, AuctionSpecialInfo_Activity.class);
                intent.putExtra("SpecialID", artistID);
                startActivity(intent);
                break;
            case R.id.lot_det_intro:
                Intent intent4 = new Intent(mContext, LotIntroActivity.class);
                intent4.putExtra("id", id);
                startActivity(intent4);
                break;
            case R.id.lot_det_note_view:
                // 笔记
                isShowNoteKeyBoard = true;
                showNoteKeyBoard();
                break;
            case R.id.iv_vioce:
                // 笔记语音
                VioceUtils vu = new VioceUtils(getActivity(), imgVoice,
                        lot_det_noteEd);
                vu.init();
                break;
            case R.id.lot_det_noteDelete:
                // 清空笔记
                lot_det_noteEd.setText("");
                break;
            default:
                break;
        }
    }

    /**
     * 分享传递到上层activity
     *
     * @return
     */
    public ShareItem getShareitem() {
        return shareItem;
    }

    /**
     * 笔记软键盘回车按钮的监听
     */
    OnEditorActionListener onEditorAction = new OnEditorActionListener() {

        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            final String searchStr = lot_det_noteEd.getText().toString().trim();
            if (actionId == EditorInfo.IME_ACTION_SEARCH
                    || (event != null && event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) {
                // do something;
                if (searchStr == null || "".equals(searchStr)) {
                    ToastUtil.toast(mContext, "您似乎忘了点什么");
                    return true;
                } else {
                    if (isNote == true) {
                        // 修改笔记
                        postNote("2");
                    } else {
                        // 添加笔记
                        postNote("1");
                    }
                    hideNoteKeyBoard();
                }
                return false;
            }
            return false;
        }
    };

    /**
     * 显示笔记软键盘
     *
     * @param strPreFix
     */
    private void showNoteKeyBoard() {
        InputMethodManager imm = (InputMethodManager) lot_det_noteEd
                .getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.toggleSoftInput(0, InputMethodManager.SHOW_FORCED);
        lot_det_noteEd.requestFocus();
        lot_det_bottomview_BtnLL.setVisibility(View.GONE);
        lot_det_noteLL.setVisibility(View.VISIBLE);
        hideView.setVisibility(View.VISIBLE);
    }

    /**
     * 隐藏笔记软键盘
     */
    private void hideNoteKeyBoard() {
        InputMethodManager imm = (InputMethodManager) mContext.getSystemService("input_method");
        if (imm != null) {
            imm.hideSoftInputFromWindow(getActivity().getWindow()
                    .getDecorView().getWindowToken(), 0);
        }
        hideView.setVisibility(View.GONE);
        lot_det_noteLL.setVisibility(View.GONE);
        lot_det_bottomview_BtnLL.setVisibility(View.VISIBLE);
    }

    /**
     * 发表/修改/删除笔记 拍品id id 笔记内容 content 用户口令 token 类型 type 1.发表笔记 2.修改笔记,3删除笔记 Y
     */
    private void postNote(String Type) {
        VolleyBasic.getInstance(getActivity()).post(
                Cache.LotAddNote,
                VolleyMap.getInstance().LotAddNote(id, Type,
                        lot_det_noteEd.getText().toString()),
                OneStateIntParser.class, new VolleyCallback() {

                    @SuppressWarnings({"unchecked", "static-access"})
                    @Override
                    public void onSuccess(VolleyData vd) {
                        // TODO Auto-generated method stub
                        OneStateIntParser bean = (OneStateIntParser) vd
                                .getData();
                        if (bean.getState() == 1) {
                            ToastUtil.toast(mContext, "发送成功");
                            isNote = true;
                            hideNoteKeyBoard();
                        } else {
                            ToastUtil.toast(mContext, "发送失败");
                        }
                    }

                    @Override
                    public void onError(VolleyError volleyError) {
                        // TODO Auto-generated method stub
                        ToastUtil.toast(mContext, "发送失败");
                    }
                });
    }


    /**
     * 星级评论监听
     */
    OnRatingBarChangeListener onRatingBar = new OnRatingBarChangeListener() {

        @Override
        public void onRatingChanged(RatingBar ratingBar, float rating,
                                    boolean fromUser) {
            // TODO Auto-generated method stub
            score = (int) rating;
        }
    };

    /**
     * 软键盘回车按钮的监听
     */
    OnEditorActionListener onEditorActionCmt = new OnEditorActionListener() {

        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            final String searchStr = replyEd.getText().toString().trim();
            if (actionId == EditorInfo.IME_ACTION_SEARCH
                    || (event != null && event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) {
                // do something;
                if (searchStr == null || "".equals(searchStr)) {
                    ToastUtil.toast(mContext, "您似乎忘了点什么");
                    return true;
                } else {
                    if (replyPosition == -1) {
                        sendComment();
                    } else {
                        replyComment();
                    }
                }
                return false;
            }
            return false;
        }
    };


    /**
     * 发表评论 机构id id 也可以是拍卖会id,专场id,拍品id 评论类型 type 1,机构，2，拍卖会，3专场，4拍品 评论内容
     * content 评分 score 1-5分
     */
    private void sendComment() {
        VolleyBasic.getInstance(getActivity()).post(
                Cache.replyComment,
                VolleyMap.getInstance().replyComment(id, "4",
                        replyEd.getText().toString(), score),
                OneStateIntParser.class, new VolleyCallback() {

                    @SuppressWarnings({"unchecked", "static-access"})
                    @Override
                    public void onSuccess(VolleyData vd) {
                        // TODO Auto-generated method stub
                        OneStateIntParser bean = (OneStateIntParser) vd
                                .getData();
                        if (bean.getState() == 1) {
                            ToastUtil.toast(mContext, "发送成功");
                            replyPosition = -1;// 恢复状态
                            replyEd.setText("");
                            replyEd.setHint("评论:");
                            mRatingBar.setRating(0);
                            pageIndex = 1;
                            ratingBarLL.setVisibility(View.GONE);
                            cmt_view.setVisibility(View.GONE);
                            cmt_view2.setVisibility(View.GONE);
                            hideCmt.setVisibility(View.GONE);
                            VolleyBasic
                                    .getInstanceNoDialog((Activity) mContext);
                            new Handler().postDelayed(new Runnable() {

                                @Override
                                public void run() {
                                    // TODO Auto-generated method stub
                                    getCmtData();
                                }
                            }, 1000);

                        } else {
                            ToastUtil.toast(mContext, "发送失败");
                        }
                    }

                    @Override
                    public void onError(VolleyError volleyError) {
                        // TODO Auto-generated method stub
                        ToastUtil.toast(mContext, "发送失败");
                    }
                });
    }

    /**
     * 回复评论 id id 机构/拍卖会/专场/拍品的id 用户口令 token 内容 content 回复那条评论的id commentid 类型
     * type 1,机构，2，拍卖会，3专场，4拍品 评分 score 评分范围0-5
     */
    private void replyComment() {
        VolleyBasic.getInstance(getActivity()).post(
                Cache.Answercomment,
                VolleyMap.getInstance().Answercomment(id, "4", replyID,
                        replyEd.getText().toString(), score),
                OneStateIntParser.class, new VolleyCallback() {

                    @SuppressWarnings({"unchecked", "static-access"})
                    @Override
                    public void onSuccess(VolleyData vd) {
                        // TODO Auto-generated method stub
                        OneStateIntParser bean = (OneStateIntParser) vd
                                .getData();
                        if (bean.getState() == 1) {
                            ToastUtil.toast(mContext, "发送成功");
                            replyPosition = -1;// 恢复状态
                            replyEd.setText("");
                            replyEd.setHint("评论:");
                            mRatingBar.setRating(0);
                            pageIndex = 1;

                            VolleyBasic.getInstanceNoDialog(getActivity());
                            // getData();
                            new Handler().postDelayed(new Runnable() {

                                @Override
                                public void run() {
                                    // TODO Auto-generated method stub
                                    getCmtData();
                                }
                            }, 1000);
                        } else {
                            ToastUtil.toast(mContext, "发送失败");
                        }
                    }

                    @Override
                    public void onError(VolleyError volleyError) {
                        // TODO Auto-generated method stub
                        ToastUtil.toast(mContext, "发送失败");
                    }
                });
    }

    void startComment(String strPreFix) {
        ratingBarLL.setVisibility(View.VISIBLE);
        cmt_view.setVisibility(View.VISIBLE);
        cmt_view2.setVisibility(View.VISIBLE);
        hideCmt.setVisibility(View.VISIBLE);
        replyEd.setHint(strPreFix);
        replyEd.setFocusable(true);
        InputMethodManager imm = (InputMethodManager) replyEd.getContext()
                .getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.toggleSoftInput(0, InputMethodManager.SHOW_FORCED);

        // mscroll.fullScroll(ScrollView.FOCUS_DOWN);
        hideCmt.setVisibility(View.VISIBLE);
        replyEd.requestFocus();
    }

    void hideKeyBoard() {
        InputMethodManager imm = (InputMethodManager) mContext
                .getSystemService("input_method");
        if (imm != null) {
            imm.hideSoftInputFromWindow(getActivity().getWindow()
                    .getDecorView().getWindowToken(), 0);
        }
        hideCmt.setVisibility(View.GONE);
        replyPosition = -1;// 恢复状态
        replyEd.setHint("");
    }


//    /**
//     * ScrollListener滚动监听
//     */
//    PullableScrollView.OnScrollListener scrollListener = new PullableScrollView.OnScrollListener() {
//        @Override
//        public void onScroll(int scrollY) {
//            int a = getScrollY();
//            if (scrollY > VeDate.dip2px(mContext, 320) - 70) {
//                if (titleHide_RL.getVisibility() == View.GONE) {
//                    setShowAnimation(titleHide_RL, 500);
//                }
//            } else {
//                if (titleHide_RL.getVisibility() == View.VISIBLE) {
//                    setHideAnimation(titleHide_RL, 500);
//                }
//            }
//            Log.e("Y", "getScrollY=" + a);
//            Log.e("Y", "scrollY=" + scrollY);
//        }
//    };


    private AlphaAnimation mHideAnimation = null;
    private AlphaAnimation mShowAnimation = null;

    /**
     * View渐隐动画效果
     */
    private void setHideAnimation(final View view, int duration) {
        if (null == view || duration < 0) {
            return;
        }
        if (null != mHideAnimation) {
            mHideAnimation.cancel();
        }
        mHideAnimation = new AlphaAnimation(1.0f, 0.0f);
        mHideAnimation.setDuration(duration);
        // mHideAnimation.setFillAfter(true);
        mHideAnimation.setAnimationListener(new Animation.AnimationListener() {

            @Override
            public void onAnimationStart(Animation arg0) {
                // TODO Auto-generated method stub

            }

            @Override
            public void onAnimationRepeat(Animation arg0) {
                // TODO Auto-generated method stub

            }

            @Override
            public void onAnimationEnd(Animation arg0) {
                // TODO Auto-generated method stub
                view.clearAnimation();
                view.setVisibility(View.GONE);
            }
        });
        view.startAnimation(mHideAnimation);
    }

    /**
     * View渐现动画效果
     */
    private void setShowAnimation(final View view, int duration) {
        if (null == view || duration < 0) {
            return;
        }
        if (null != mShowAnimation) {
            mShowAnimation.cancel();
        }
        mShowAnimation = new AlphaAnimation(0.0f, 1.0f);
        mShowAnimation.setDuration(duration);
        // mShowAnimation.setFillAfter(true);
        mShowAnimation.setAnimationListener(new Animation.AnimationListener() {

            @Override
            public void onAnimationStart(Animation arg0) {
                // TODO Auto-generated method stub
                view.setVisibility(View.VISIBLE);
            }

            @Override
            public void onAnimationRepeat(Animation arg0) {
                // TODO Auto-generated method stub
            }

            @Override
            public void onAnimationEnd(Animation arg0) {
                // TODO Auto-generated method stub
                view.clearAnimation();
            }
        });
        view.startAnimation(mShowAnimation);
    }

    public int getScrollY() {
        int top = 200;
        return -top;
    }

    //透明状态栏
    private void HindStatusBar() {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            Window window = getActivity().getWindow();
            // Translucent status bar
            window.setFlags(
                    WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS,
                    WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        }
    }


    // 广播监听
    BroadcastReceiver broadcastReceiver = new BroadcastReceiver() {

        @Override
        public void onReceive(Context context, Intent intent) {
            if (intent.getBooleanExtra("Collect", false)) {
                //是否为收藏
                if (intent.getBooleanExtra("isCollect", true)) {
                    //设置为已收藏
                    itemMain.getLotInfo().setIs_collection(1);
                } else {
                    //设置为未收藏
                    itemMain.getLotInfo().setIs_collection(0);
                }
            } else if (intent.getBooleanExtra("isReply", false)) {
                //判断是否为适配器发送的回复推送
                int position = intent.getIntExtra("Position", -1);
                if (position != -1) {
                    if (more_list != null && more_list.size() != 0) {
                        if (!TextUtils.isEmpty(AppUtil.getUser().getUid())) {
                            replyPosition = position;
                            startComment("");
                            replyEd.setHint("@" + more_list.get(position).getRealname());
                            replyID = more_list.get(position).getMessid();
                        } else {
                            AppUtil.Logout(mContext);
                            AppUtil.LoginVer(mContext);
                        }
                    }
                }
            }
            ;
        }
    };

    @Override
    public void onDestroy() {
        super.onDestroy();
        // 关闭广播
        mContext.unregisterReceiver(broadcastReceiver);
    }
}
